<script lang="ts" setup>
import {ref} from "vue";
import {orderEdit} from "../../api/order";
import {useRoute} from "vue-router";
import router from "../../router";

const route = useRoute()
let form = ref({})

async function upload() {
  await orderEdit({...form})
  setTimeout(() => {
    router.push('/order')
  }, 1000)
}

let {id}: any = route.query
let data = JSON.parse(id)
form = {...data}
</script>
<template>
  <el-card class="box-card">
    <div slot="header" class="clearfix">
      <span>订单编辑</span>
    </div>
    <el-form :model="form" label-width="120px" class="form">
      <el-form-item prop="orderNo" label="订单号:">
        <el-input v-model="form.orderNo"></el-input>
      </el-form-item>
      <el-form-item prop="orderTime" label="下单时间:">
        <el-date-picker
            v-model="form.orderTime"
            format="HH:mm:ss"
            type="datetime"
            placeholder="选择日期时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item prop="phone" label="联系电话:">
        <el-input v-model="form.phone"></el-input>
      </el-form-item>
      <el-form-item prop="consignee" label="收货人:">
        <el-input v-model="form.consignee"></el-input>
      </el-form-item>
      <el-form-item prop="deliverAddress" label="送货地址:">
        <el-input v-model="form.deliverAddress"></el-input>
      </el-form-item>
      <el-form-item prop="deliveryTime" label="送达时间:">
        <el-date-picker
            v-model="form.deliveryTime"
            format="HH:mm:ss"
            type="datetime"
            placeholder="选择日期时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item prop="remarks" label="备注:">
        <el-input v-model="form.remarks"></el-input>
      </el-form-item>
      <el-form-item prop="orderAmount" label="订单金额:">
        <el-input-number
            v-model="form.orderAmount"
            :min="0"
            :max="100"
        ></el-input-number>
      </el-form-item>
      <el-form-item prop="orderState" label="订单状态">
        <el-select v-model="form.orderState" placeholder="订单状态">
          <el-option label="已完成" value="已完成"></el-option>
          <el-option label="进行中" value="进行中"></el-option>
          <el-option label="派送中" value="派送中"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="">
        <el-button type="primary" @click="upload"
        >上传
        </el-button
        >
      </el-form-item
      >
    </el-form>
  </el-card>
</template>
<style lang="scss" scoped>
.form {
  width: 500px;
}
</style>